const app = getApp();
Component({
	/**
	 * 组件的初始数据
	 */
	data: {
		isIphoneX: app.globalData.systemInfo.model.search('iPhone X') != -1 ? true : false,
		selected: 0,
		color: "#7A7E83",
		selectedColor: "#015C61",
		list: [
			{
				pagePath: "/pages/index/index",
				iconPath: "icon/tab1.png",
				selectedIconPath: "icon/tab1-active.png",
				text: "首页"
			},
			{
				pagePath: "/pages/list/index",
				iconPath: "icon/tab2.png",
				selectedIconPath: "icon/tab2-active.png",
				text: "地图"
			},
			//  扫码是我要凸起的tab
			{
				pagePath: "/pages/tab-code/index",
				iconPath: "icon/icon_release.png",
				// selectedIconPath: "/image/tab-code.png",
				text: "扫码",
				isSpecial: true
			},
			{
				pagePath: "/pages/tab-welfare/index",
				iconPath: "icon/tab3.png",
				selectedIconPath: "icon/tab3-active.png",
				text: "福利"
			},
			{
				pagePath: "/pages/tab-my/index",
				iconPath: "icon/tab4.png",
				selectedIconPath: "icon/tab4-active.png",
				text: "我的"
			}
		]
	},

	/**
	 * 组件的方法列表
	 */
	methods: {

		switchTab(e) {
			const data = e.currentTarget.dataset
			console.log(data)
			if (!data.click) {
				// 跳转页面
				const url = data.path
				wx.switchTab({ url })
				this.setData({
					selected: data.index
				})
			} else {
				// 扫码  凸起
				wx.scanCode({
					onlyFromCamera: true,
					success(res) {
						console.log(res)
					},
					fail(err) {
						console.log(err)
						wx.showToast({
							title: '扫码失败',
							icon: 'loading',
							duration: 1500
						})
					}
				})
			}
		}

	}
})
